/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.cs.account.AccessManager.AttrRightChecker;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.AttributeClass;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.Zimlet;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetZimlet
/*    */   extends AdminDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 39 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 40 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 42 */     Set<String> reqAttrs = getReqAttrs(request, AttributeClass.zimletEntry);
/*    */     
/* 44 */     Element z = request.getElement("zimlet");
/* 45 */     String n = z.getAttribute("name");
/*    */     
/* 47 */     Zimlet zimlet = prov.getZimlet(n);
/*    */     
/* 49 */     if (zimlet == null) {
/* 50 */       throw AccountServiceException.NO_SUCH_ZIMLET(n);
/*    */     }
/* 52 */     AdminAccessControl aac = checkRight(zsc, context, zimlet, AdminRight.PR_ALWAYS_ALLOW);
/*    */     
/* 54 */     Element response = zsc.createElement(AdminConstants.GET_ZIMLET_RESPONSE);
/* 55 */     encodeZimlet(response, zimlet, reqAttrs, aac.getAttrRightChecker(zimlet));
/*    */     
/* 57 */     return response;
/*    */   }
/*    */   
/*    */   static void encodeZimlet(Element response, Zimlet zimlet) throws ServiceException {
/* 61 */     encodeZimlet(response, zimlet, null, null);
/*    */   }
/*    */   
/*    */   static void encodeZimlet(Element response, Zimlet zimlet, Set<String> reqAttrs, AccessManager.AttrRightChecker attrRightChecker) throws ServiceException
/*    */   {
/* 66 */     Element zim = response.addElement("zimlet");
/* 67 */     zim.addAttribute("name", zimlet.getName());
/* 68 */     zim.addAttribute("id", zimlet.getId());
/* 69 */     String keyword = zimlet.getAttr("zimbraZimletKeyword");
/* 70 */     if (keyword != null)
/* 71 */       zim.addAttribute("hasKeyword", keyword);
/* 72 */     Map<String, Object> attrs = zimlet.getUnicodeAttrs();
/* 73 */     ToXML.encodeAttrs(zim, attrs, reqAttrs, attrRightChecker);
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 78 */     relatedRights.add(Rights.Admin.R_getZimlet);
/* 79 */     notes.add(String.format("Attributes that are not allowed to be get by the authenticated admin will be returned as <a n=\"{attr-name}\" pd=\"1\"/>.To allow an admin to get all attributes, grant the %s right", new Object[] { Rights.Admin.R_getZimlet.getName() }));
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/GetZimlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */